local skel = fk.CreateSkill {
    name = "gai__shuaizuo",
  }
  
  Fk:loadTranslationTable{
    ["gai__shuaizuo"] = "衰祚",
    [":gai__shuaizuo"] = "每回合各限一次，当你造成或受到伤害后，你可以弃置受伤角色两张牌，然后本回合所有角色只能使用这些花色的牌。",
  
    ["@rmt__shuaizuo-turn"] = "衰祚",
    ["#rmt__shuaizuo-invoke"] = "衰祚：是否弃置 %dest 两张牌？本回合所有角色只能使用这些花色的牌",
    ["#rmt__shuaizuo-discard"] = "衰祚：弃置 %dest 两张牌",
  }
  
  local spec = {
    anim_type = "control",
    can_trigger = function(self, event, target, player, data)
      if target == player and player:hasSkill(skel.name) and player:usedEffectTimes(self.name, Player.HistoryTurn) == 0 then
        local room = player.room
        local turn_event = room.logic:getCurrentEvent():findParent(GameEvent.Turn)
        if turn_event == nil then return end
        local damage_event = room.logic:getCurrentEvent()
        if not damage_event then return end
        if not data.to.dead and not data.to:isNude() then
          if data.to == player then
            if not table.find(player:getCardIds("he"), function (id)
              return not player:prohibitDiscard(id)
            end) then return end
          end
        end
        return true
      end
    end,
    on_cost = function (self, event, target, player, data)
      if player.room:askToSkillInvoke(player, {
        skill_name = skel.name,
        prompt = "#rmt__shuaizuo-invoke::"..data.to.id,
      }) then
        event:setCostData(self, {tos = {data.to}})
        return true
      end
    end,
    on_use = function(self, event, target, player, data)
      local room = player.room
      local cards = {}
      if data.to == player then
        cards = room:askToDiscard(player, {
          min_num = 2,
          max_num = 2,
          include_equip = true,
          skill_name = skel.name,
          cancelable = false,
          prompt = "#rmt__shuaizuo-discard::"..player.id,
        })
      else
        cards = data.to:getCardIds("he")
        if #cards > 2 then
          cards = room:askToChooseCards(player, {
            target = data.to,
            min = 2,
            max = 2,
            flag = "he",
            skill_name = skel.name,
            prompt = "#rmt__shuaizuo-discard::"..data.to.id,
          })
        end
        room:throwCard(cards, skel.name, data.to, player)
      end
      local suits = {}
      for _, id in ipairs(cards) do
        local suit = Fk:getCardById(id):getSuitString(true)
        if suit ~= "log_nosuit" then
          table.insertIfNeed(suits, suit)
        end
      end
      if #suits == 0 then return end
      for _, p in ipairs(room.alive_players) do
        local mark = p:getTableMark("@rmt__shuaizuo-turn")
        for _, suit in ipairs(suits) do
          table.insertIfNeed(mark, suit)
        end
        room:setPlayerMark(p, "@rmt__shuaizuo-turn", mark)
      end
    end,
  }
  skel:addEffect(fk.Damage, spec)
  skel:addEffect(fk.Damaged, spec)
  
  skel:addEffect("prohibit", {
    prohibit_use = function(self, player, card)
      return player:getMark("@rmt__shuaizuo-turn") ~= 0 and card and card.suit ~= Card.NoSuit and
        not table.contains(player:getTableMark("@rmt__shuaizuo-turn"), card:getSuitString(true))
    end,
  })
  
  return skel